package sketch.ounit.fuzz;

import java.util.List;

import sketch.ounit.Values;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class AssembledSequenceObjectCreationCombinationTest extends TestCase {

	public static Test suite() {
		return new TestSuite(AssembledSequenceObjectCreationCombinationTest.class);
	}
	
	public void testSequenceCreationCombinations() {
		int num_to_create = 10;
		int time_limit = 5;
		
		Class<?>[] classes = new Class<?>[]{treemap.TreeMap.class, sketch.ounit.fuzz.PseduoProgram.class};
		SharedSequencePool.init_pool(time_limit, classes);
		
		while(num_to_create -- > 0) {
			
			//start a new round
			SharedSequencePool.startNewRound();
			Throwable throwable = null;
			
			/*** The code needs to be executed reflectively : start ***/
			try {
			  PseduoProgram p = Values.randomCreate(sketch.ounit.fuzz.PseduoProgram.class, 999, "hell-world");
			  System.out.println(p.toString());
			  treemap.TreeMap map = Values.randomCreate(treemap.TreeMap.class);
			  p.needTreeMap(map);
			  System.out.println(p.toString());
			} catch (Exception e) {
				System.out.println(" \n !!! fail to generate tests in round: " + num_to_create + "\n");
				throwable = e; 
			}
			/*** The code needs to be executed reflectively : end ***/
			
			//end a round
			if(throwable == null) {
			  List<String> code = SharedSequencePool.getGeneratedCode();
			  System.out.println(code);
			}
		}
	}
}
